﻿namespace Silverlight.Treemap.Extensions
{
    using System;
    using System.Windows;

    public static class FrameworkElementExtensions
    {
        public static T GetResource<T>(this FrameworkElement frameworkElement, string key) where T : DependencyObject
        {
            T resource = frameworkElement.Resources[key] as T;

            if (resource == null)
            {
                throw new Exception(string.Format("Unable to find the resource {0} which is required.", key));
            }

            return resource;
        }
    }
}